package cn.miaopasi.learn.websocket.stomp;

import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * 消息推送
 *
 * @author Administrator
 */
@Controller
public class SubController {

    @Resource
    private SimpMessagingTemplate template;

    /**
     * 广播
     *
     * @param message 消息接受对象
     */
    @MessageMapping("/subscribe")
    public void subscribe(ReceiveMessage message) {
        template.convertAndSend("/topic/getResponse", message.getFromUserName());
    }

}
